package at.brandl.wwi;

import java.util.ArrayList;
import java.util.List;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class WhereWasIOverlay extends ItemizedOverlay<OverlayItem> {

	private final List<OverlayItem> items = new ArrayList<OverlayItem>();
	private final Context context;
	
	public WhereWasIOverlay(Drawable defaultMarker, Context context) {
		super(boundCenterBottom(defaultMarker));
		this.context = context;
	}

	public void addOverlayItem(OverlayItem item)
	{
		items.add(item);
	}
	
	public void populateOverlay()
	{
		super.populate();
	}
	
	@Override
	protected OverlayItem createItem(int i) {
		return items.get(i);
	}

	@Override
	public int size() {
		return items.size();
	}

	@Override
	protected boolean onTap(int index) {
	  OverlayItem item = items.get(index);
	  AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
	  dialogBuilder.setTitle(item.getTitle());
	  dialogBuilder.setMessage(item.getSnippet());
	  dialogBuilder.show();
	  return true;
	}
	
	
}
